﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Data;
using DevExpress.XtraGrid.Views.Grid;
using QuanLyKho.QuanLyKho;

namespace QuanLyKho.Control
{
    public partial class Kho_Khohang : UserControl
    {
        public Kho_Khohang()
        {
            InitializeComponent();
            LoadData();
        }

        public void LoadData()
        {
            gridKho.DataSource = DataAll.SelectAll("Kho_KhoHang", "*", "");
            SetPropertiesGrid();
        }

        public void SetPropertiesGrid()
        {
            gvKho.FocusRectStyle = DrawFocusRectStyle.RowFullFocus;
            gvKho.OptionsView.ShowGroupPanel = false;
            gvKho.OptionsView.ColumnAutoWidth = true;
            gvKho.OptionsFind.AlwaysVisible = true;
            gvKho.Columns["IDKhoHang"].Visible = false;
        }

        private void gvKho_DoubleClick(object sender, EventArgs e)
        {
            Kho_Khohang_VatTu.IDKhoHang = gvKho.Columns["IDKhoHang"].View.GetRowCellDisplayText(gvKho.FocusedRowHandle, "IDKhoHang");
            var kho = new Kho_Khohang_VatTu();
            kho.ShowDialog();
            LoadData();
            Kho_Khohang_VatTu.IDKhoHang = "0";
        }
    }
}
